#{extends 'main.html' /}

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Manage Identity</title>
</head>
<script type="text/javascript">
window.fbAsyncInit = function(){
	  FB.init({ appId:'388171657886328', status:true,  cookie:true, xfbml:true});
	  
};

function alerting(){	  
FB.getLoginStatus(function(response){
	if (response.status === 'connected') {
	    // the user is logged in and has authenticated your
	    // app, and response.authResponse supplies
	    // the user's ID, a valid access token, a signed
	    // request, and the time the access token 
	    // and signed request each expire
	    var uid = response.authResponse.userID;

	    alert("Sorry this account is already connected to our system. "
	    		+ "\n Please log in with another Facebook account to continue");
	  } 
	else
	  {
		if (response.status === 'not_authorized') {
	    // the user is logged in to Facebook, 
	    // but has not authenticated your app
		window.location = "@{connectProfile(abstractProfile)}";
	  	} 
		else {
	    // the user isn't logged in to Facebook.
	    alert("Please log into Facebook to continue");
		}
	  }
	  });
}
	  
	  

</script>


<body>
	<div id="fb-root"></div>
	<script>
		// Load the SDK Asynchronously
		(function(d) {
			var js, id = 'facebook-jssdk';
			if (d.getElementById(id)) {
				return;
			}
			js = d.createElement('script');
			js.id = id;
			js.async = true;
			js.src = "//connect.facebook.net/en_US/all.js";
			d.getElementsByTagName('head')[0].appendChild(js);
		}(document));
		
	</script>

	<h3>You have ${num} Facebook accounts connected to this identity</h3>

	<br>
	<br> #{if num>0} 
	#{list items:0..profileListSize, as:'i'}
	<li>Account : ${i+1} 
	<br> Account Display Name : ${profileList[i].displayName} 
		<br> Account Gender : ${profileList[i].gender} 
		<br> Account Link : <a href=${profileList[i].link}> LINK </a> 
		<br> Account username: ${profileList[i].username} 
		<br> Account Profile Picture: 
			<img src=${profileList[i].ppLink} align="middle" type="large" alt="Profile Picture" align="top" />
		<br> Account last update: ${profileList[i].updated_time}
		<br> Current Status Message: ${statusMsgs[i]}
		<br>
		<br>
	</li> 
	#{/list} #{/if}
	<br>
	<button onclick="alerting()">
	Connect another Facebook Account to this identity!
	</button>
	

	<br>
	<a href="@{AbstractProfiles.deleteIdentity(abstractProfile)}">Delete
		this identity!</a>
	<br>
	<a href="@{AbstractProfiles.manageIdentities}">Manage your
		identities</a>
	<br>
	<a href="@{Application.homePage}">Back to Home Page</a>
	<br>
	<a href="http://localhost:9000/logout">Log out!</a>

</body>
</html>